<?php
!function_exists('readover') && exit('Forbidden');

if(file_exists(D_P."data/bbscache/hits.txt")){
	if($hitsize<5120){
		$hitarray=explode("\t",readover(D_P."data/bbscache/hits.txt"));
		P_unlink(D_P."data/bbscache/hits.txt");
		$hits=array_count_values($hitarray);
		$count=0;
		$hits_a=array();
		foreach($hits as $key=>$value){
			if(is_numeric($key)){
				$value = $value > 4 ? round($value/10)*10-3 : 3;
				$hits_a[$value][]=$key;
			}
		}
		foreach($hits_a as $key=>$val){
			$db->update("UPDATE pw_threads SET hits=hits+'$key' WHERE tid IN(".implode(',',$val).")");
			$count++;
			if($count>300) break;
		}
		$nowtime=($timestamp-$tdtime)/3600;
		$hit_control=floor($nowtime/$db_hithour)+1;
		if($hit_control>24/$db_hithour)$hit_control=1;
		$db->update("UPDATE pw_bbsinfo SET hit_control='$hit_control',hit_tdtime='$tdtime' WHERE id=1");
		unset($hitarray,$hits);
	} else{
		P_unlink(D_P."data/bbscache/hits.txt");
	}
}
?>